package Sort;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2024/8/26-上午9:19
 * Since  :   1.0
 * Version:   1.0
 */
public class BubbleSort {

    public static int[] bubble(int arr[]) {
        boolean flag = false;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    flag = true;
                    int temp = arr[j + 1];
                    arr[j + 1] = arr[j];
                    arr[j] = temp;
                }
            }
            if (!flag) {
                break;
            } else {
                flag = false;
            }


        }
        return  arr;

    }


}
